package com.evil.application.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.evil.application.pojo.dto.view.config.filter.FilterSourceDTO;
import com.evil.application.pojo.entity.ApplicationFilterGroup;
import com.evil.common.core.util.StreamUtil;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface ApplicationFilterGroupMapper extends BaseMapper<ApplicationFilterGroup> {

    List<ApplicationFilterGroup> findByIds(@Param("groupIds") Collection<Long> groupIds);

    default Map<Long, ApplicationFilterGroup> findMapByIds(Collection<Long> groupIds) {
        return StreamUtil.toMapK(this.findByIds(groupIds), ApplicationFilterGroup::getFilterGroupId);
    }

    List<ApplicationFilterGroup> findBySource(FilterSourceDTO filterSourceDTO);

    default Map<Long, ApplicationFilterGroup> findMapBySource(FilterSourceDTO filterSourceDTO) {
        return StreamUtil.toMapK(this.findBySource(filterSourceDTO), ApplicationFilterGroup::getFilterGroupId);
    }
}